using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ItemactMap : EntityTypeConfiguration<Itemact>
    {
        public ItemactMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ITEM, t.LOCATION, t.DATE, t.QTY });

            // Properties
            this.Property(t => t.ITEM)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.LOCATION)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.TRANSCODE)
                .HasMaxLength(1);

            this.Property(t => t.DESC)
                .HasMaxLength(30);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Itemact");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.LOCATION).HasColumnName("LOCATION");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.QTY).HasColumnName("QTY");
            this.Property(t => t.TRANSCODE).HasColumnName("TRANSCODE");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.PUREWGHT).HasColumnName("PUREWGHT");
            this.Property(t => t.DEPARTMENT).HasColumnName("DEPARTMENT");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.expiryDate).HasColumnName("expiryDate");

            // Relationships
            this.HasRequired(t => t.Item1)
                .WithMany(t => t.Itemacts)
                .HasForeignKey(d => d.ITEM);

        }
    }
}
